package cn.lanqiao.system.service.impl;

import cn.lanqiao.common.entity.Arrangement;
import cn.lanqiao.common.entity.Film;
import cn.lanqiao.common.entity.Order;
import cn.lanqiao.common.vo.ArrangementVO;
import cn.lanqiao.system.mapper.ArrangementMapper;
import cn.lanqiao.system.mapper.FilmMapper;
import cn.lanqiao.system.mapper.OrderMapper;
import cn.lanqiao.system.service.ArrangementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class ArrangementServiceImpl implements ArrangementService{
    @Autowired
    private ArrangementMapper arrangementMapper;
    @Autowired
    private FilmMapper filmMapper;
    @Autowired
    private OrderMapper orderMapper;
    @Override
    public ArrangementVO findByFilmId(Integer filmId) {
       // ArrangementVO arrangement=arrangementMapper.findByFilmId(filmId);
        //ArrangementVO arrangementVO=new ArrangementVO();
       // arrangementVO.setArrangements(arrangement);
        //arrangementVO.setFilm(filmMapper.findById(filmId));
        return arrangementMapper.findByFilmId(filmId);

    }

    @Override
    public List<Integer> getSeatsHaveSelected(Integer id) {
        List<Order> orders=orderMapper.findByOrderId(id);

        List<Integer> seatList=new ArrayList<>();
        for(Order o:orders){
            String[] s=o.getSeat().split("号");
            for(String S : s){
                 seatList.add(Integer.parseInt(S));
            }
        }
        return seatList;
    }
}
